package com.sinba.common.system.action;

import com.opensymphony.xwork2.ActionSupport;

import com.sinba.common.dto.PageDTO;
import com.sinba.common.system.dto.OrderDTO;
import com.sinba.common.system.service.IOrderService;

import org.springframework.beans.factory.annotation.Autowired;

@SuppressWarnings( "serial" )
public class OrderAction
    extends ActionSupport
{
    @Autowired
    private IOrderService orderService;
    private PageDTO pageDTO;
    private OrderDTO orderDTO = new OrderDTO(  );
    private int page = 1;
    private int rows = 10;
    private String sidx;
    private String sord;
    private Long[] ids;
    private Long orderId;
    private String orderNo;

    public PageDTO getPageDTO(  )
    {
        return pageDTO;
    }

    public void setPageDTO( PageDTO pageDTO )
    {
        this.pageDTO = pageDTO;
    }

    public OrderDTO getOrderDTO(  )
    {
        return orderDTO;
    }

    public void setOrderDTO( OrderDTO orderDTO )
    {
        this.orderDTO = orderDTO;
    }

    public int getPage(  )
    {
        return page;
    }

    public void setPage( int page )
    {
        this.page = page;
    }

    public int getRows(  )
    {
        return rows;
    }

    public void setRows( int rows )
    {
        this.rows = rows;
    }

    public String getSidx(  )
    {
        return sidx;
    }

    public void setSidx( String sidx )
    {
        this.sidx = sidx;
    }

    public String getSord(  )
    {
        return sord;
    }

    public void setSord( String sord )
    {
        this.sord = sord;
    }

    public Long[] getIds(  )
    {
        return ids;
    }

    public void setIds( Long[] ids )
    {
        this.ids = ids;
    }

    public Long getOrderId(  )
    {
        return orderId;
    }

    public void setOrderId( Long orderId )
    {
        this.orderId = orderId;
    }

    public String getOrderNo(  )
    {
        return orderNo;
    }

    public void setOrderNo( String orderNo )
    {
        this.orderNo = orderNo;
    }

    public String findOrderPager(  )
    {
        int start = ( page - 1 ) * rows;
        orderDTO.setStart( start );
        orderDTO.setLimit( rows );
        pageDTO = orderService.findOrderPager( orderDTO, sord, sidx );
        pageDTO.setPage( page );
        pageDTO.setRows( rows );

        return SUCCESS;
    }

    public String deteleOrder(  )
    {
        orderService.deleteOrder( ids );

        return SUCCESS;
    }

    public String saveOrder(  )
    {
        orderId = orderService.saveOrder( orderDTO );

        return "orderPage";
    }

    public String updateOrder(  )
    {
        orderService.updateOrder( orderNo );

        return SUCCESS;
    }
    ;
}
